package org.prem.springmvc.hello;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class StudentAdmissionController11 {
	
	@RequestMapping(value="/admissionForm11",method=RequestMethod.GET)
	public ModelAndView getAdmissionForm(){
		ModelAndView modelAndView = new ModelAndView("AdmissionForm11");
		return modelAndView;
	}

	@RequestMapping(value="/submitAdmissionForm11",method=RequestMethod.POST)
	public ModelAndView submitAdmissionForm(@RequestParam("studentName") String name,@RequestParam("studentHobby") String hobby){
		ModelAndView modelAndView = new ModelAndView("AdmissionSuccess11");
		Student student = new Student();
		student.setStudentName(name);
		student.setStudentHobby(hobby);
		modelAndView.addObject("student", student);
		return modelAndView;
	}
	
	@RequestMapping(value="/submitAdmissionFormModelAttribute11",method=RequestMethod.POST)
	public ModelAndView submitAdmissionFormModelAttribute(@ModelAttribute("student") Student student){
		ModelAndView modelAndView = new ModelAndView("AdmissionSuccess11");
		return modelAndView;
	}
}
